#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;
const LL N = 1e4 + 5;

LL n, m, x, a[N], sum[N]; //sum[i]--前缀和数组，前i项的和
LL maxl[N];             //maxl[i]--存储所有为i的最大子段和
LL ansl[N];             //ansl[i]--存储所有长度>=i的最大子段和
int main() {
    scanf("%lld %lld", &n, &m);

    for (LL i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        sum[i] = sum[i - 1] + a[i];
    }

    memset(maxl, -0x3f, sizeof maxl);
    memset(ansl, -0x3f, sizeof ansl);

    //计算所有长度下带来的最大连续子段和
    for (LL len = 1; len <= n; len++)   //枚举区间长度
        for (LL r = len; r <= n; r++)     //枚举右端点
            maxl[len] = max(maxl[len], sum[r] - sum[r - len]);

    //计算ansl[]长度>=i的最大子段和
    for (LL len = n; len >= 1; len--)
        ansl[len] = max(ansl[len + 1], maxl[len]);

    //进行m次查询
    while (m--) {
        scanf("%lld", &x);
        printf("%lld\n", ansl[x]);
    }

    return 0;
}